package com.mine.controller.strategy;

import java.io.Serializable;

/**
 * 游戏关卡数据模型
 */
public class GameLevel implements Serializable {
	// 关卡号常量
	public static final int CUSTOM = 0, BASIC = 1, INTERMEDIATE = 2, EXPENSE = 3;
	//策略模式获取游戏难度
	public static DifficultyLevel basic = new Basic();
	public static DifficultyLevel intermediate = new Intermediate();
	public static DifficultyLevel expense = new Expense();
	public static DifficultyLevel custom = new Custom(40,16,16);
	// 游戏关卡默认数据
	public static final GameLevel
			LEVEL_BASIC = new GameLevel(GameLevel.BASIC, "初级",basic),
			LEVEL_INTERMEDIATE = new GameLevel(GameLevel.INTERMEDIATE, "中级", intermediate),
			LEVEL_EXPENSE = new GameLevel(GameLevel.EXPENSE, "高级", expense),
			LEVEL_CUSTOM = new GameLevel(GameLevel.CUSTOM, "自定义", custom);
	// 自定义关卡最大,最小值
	public static final int MAX_X = 30, MAX_Y = 24, MAX_AMOUNT = 667,
			MIN_X = 9, MIN_Y = 9, MIN_AMOUNT = 10;
	
	//关卡默认地雷数
	public int mineAmount;
	//关卡格子最大宽度和高度
	public int maxX, maxY;
	//关卡号
	public int no;
	//关卡名称
	public String name;

	public GameLevel(int level, String name,DifficultyLevel difficultyLevel) {
		this.mineAmount = difficultyLevel.getMineAmount();
		this.maxX = difficultyLevel.getMaxX();
		this.maxY = difficultyLevel.getMaxY();
		this.no = level;
		this.name = name;
	}

	public GameLevel() {
		this.name = null;
	}

	public static final GameLevel getGameLevelByNo(int no) {
		switch (no) {
		case GameLevel.BASIC:
			return GameLevel.LEVEL_BASIC;
		case GameLevel.INTERMEDIATE:
			return GameLevel.LEVEL_INTERMEDIATE;
		case GameLevel.EXPENSE:
			return GameLevel.LEVEL_EXPENSE;
		}
		return GameLevel.LEVEL_CUSTOM;
	}
}
